﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Kinect_Interface_Prototype_1.Interface_Design
{
    public partial class OnOffSwitch : OnOffControl
    {
        private bool active;
        public bool Active 
        { 
            get { return active; } 
            set 
            {
                active = value;

                if (!active)
                {
                    // turn control off and deactivate it
                    state = false;
                    this.BackgroundImage = Constants.DeactivatedSwitch;
                }
            } 
        }

        public OnOffSwitch(int x, int y) : base(x,y)
        {
            active = true;
            SetImage();
            this.Size = new Size(160, 63);
        }

        public OnOffSwitch(bool state, int x, int y) : base(state, x, y)
        {
            active = true;
            SetImage();
            this.Size = new Size(160, 63);
        }

        protected override void SetImage()
        {
            if (active)
                this.BackgroundImage = state ? Constants.OnSwitch : Constants.OffSwitch;
        }

        protected override void OnClick(EventArgs e)
        {
            if (active)
            {
                ToggleState(!state);

                base.OnClick(e);
            }
        }
    }
}
